<template>
	<view>
		<uni-popup ref="popup" type="bottom">
			<view class="bg-white padding-bottom">
				<uni-section title="添加沟通记录" type="circle">
					<template v-slot:right>
						<view @click="close">关闭</view>
					</template>
				</uni-section>
				<view class="radius padding-sm bg-yellow " style="color: #fff;">选择客户时 务必注意手机号和姓名</view>
				<view style="display: flex;" class="padding-sm">
					<uni-easyinput ConfirmType="search" type="text" suffixIcon="search" confirmType="search" v-model="q"
						placeholder="学生姓名/家长手机号" @iconClick="iconClick" @confirm="iconClick">
					</uni-easyinput>
					<button @click="iconClick" type="primary" class=" cu-btn  bg-blue  round margin-left-xs">
						查询</button>
				</view>

				<scroll-view scroll-y="true" style="height: 600rpx">
					<customerListIetm :customer-list="customerList" @clickCustomer="clickCustomer" clickNo>
					</customerListIetm>
				</scroll-view>

			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {
		getListByParentOrStudent
	} from '@/api/customer/index.js'
	import {
		formatTime
	} from '@/utils/validate'
	import customerListIetm from "@/pages/marketing/customer/customerListIetm.vue"
	export default {
		components: {
			customerListIetm
		},
		data() {
			return {
				q: '',
				customerList: [], //客户列表
			}
		},
		props: {
			customerId: null,

			customer: {}
		},
		methods: {
			open(data) {
				this.$refs.popup.open()
			},
			/**
			 * 搜索客户
			 */
			iconClick() {
				this.getListByParentOrStudent()
			},
			/**
			 * 按条件查询客户
			 */
			async getListByParentOrStudent() {
				this.customerIndex = null
				this.customerList = []
				const {
					data
				} = await getListByParentOrStudent({
					query: this.q
				})
				if (data.length == 0) {
					uni.showToast({
						title: "没有查询到符合条件的学生",
						icon: "none"
					})
					return
				}

				this.customerList = data

			},
			close() {
				Object.assign(this.$data, this.$options.data());
				this.$refs.popup.close()
				// uni.showTabBar();
				this.$emit('refresh')
			},
			clickCustomer(data) {
				this.$emit('clickCustomer', data)
				this.close()
			}
		}
	}
</script>

<style>
</style>